import React, { Component } from 'react';
// 导入路由相关组件
import { HashRouter, Switch, Route, Redirect } from "react-router-dom"
// 导入页面组件
import Layout from "@/layout"
import Login from "@/views/Login"
import NotFound from "@/views/NotFound"
import Menu from "@/views/System/Menu"
import Role from "@/views/System/Role"
import User from "@/views/System/User"
import Index from "@/views/Index"


class AppRouter extends Component {
    render() {
        console.log('AppRouterAppRouter');
        return (
            <HashRouter>
                <Switch>
                    <Route path="/" exact>
                        <Redirect to="/admin" />
                    </Route>
                    <Route path="/admin"  render={(props) =>{
                        return (
                            <Layout {...props} >
                               <Switch>
                                    <Route path="/admin/" exact component={Index}></Route>
                                    <Route path="/admin/menu" component={ Menu }></Route>
                                    <Route path="/admin/role" component={ Role }></Route>
                                    <Route path="/admin/user" component={ User }></Route>
                               </Switch>
                            </Layout>
                        )
                    } } />
                    <Route path="/login" component={Login}></Route>
                    <Route path="/404" component={NotFound}></Route>
                    <Redirect to="/404" />
                </Switch>
            </HashRouter>
        );
    }
}

export default AppRouter
